package com.systop.common.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 王思淼
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult {

    /**
     * 状态码
     */
    private Integer code;
    /**
     * 返回消息
     */
    private String msg;
    /**
     * 数据总量
     */
    private int count;
    /**
     * 当前分页数据
     */
    private Object data;

    public static CommonResult build(Integer code, String msg, int count, Object data) {
        return new CommonResult(code, msg, count, data);
    }

    public static CommonResult build(Integer code, String msg) {
        return new CommonResult(code, msg, 0, null);
    }

    public static CommonResult ok() {
        return new CommonResult(200, "ok", 0, null);
    }

    public static CommonResult ok(Object object) {
        return new CommonResult(200, "ok", 0, object);
    }

    public static CommonResult fail() {
        return new CommonResult(500, "失败", 0, null);
    }

}
